package com.woyou.ui.activity;

import java.util.ArrayList;
import java.util.List;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

import com.citaq.ideliver.R;
import com.woyou.bean.Goods;
import com.woyou.bean.Info;
import com.woyou.ui.activity.orderdetail.OrderDetailActivity;
import com.woyou.ui.adapter.ReturnOrderAdapter;
import com.woyou.utils.eventbus.EventCloseFM;
import com.woyou.utils.eventbus.EventRestConfirm;

import android.util.Log;
import android.widget.ListView;
import android.widget.RelativeLayout;
import de.greenrobot.event.EventBus;

@EActivity(R.layout.include_returnorder)
public class AdjustOrderActivity extends BaseActivity {
	//下单订单有出入
	@ViewById
	RelativeLayout include_returnorder_view;
	@ViewById
	ListView include_returnorder_lv;
	ReturnOrderAdapter returnOrderAdapter;
	@ViewById
	RelativeLayout include_returnorder_adjustorder;
	List<Goods> goodsList=new ArrayList<Goods>();
	protected Class clazz;
	EventCloseFM closeFM;// 关闭FM事件

	
	@Override
	public void onResume() {
		super.onResume();
		Info receiveInfo = getInfoBean();
		Object data = receiveInfo.getData();
		goodsList=(List<Goods>)data;
		Log.i("goodsList", ""+goodsList.toString());
//		if(returnOrderAdapter==null){
			returnOrderAdapter=new ReturnOrderAdapter(mActivity,goodsList);
			include_returnorder_lv.setAdapter(returnOrderAdapter);
//		}
		returnOrderAdapter.notifyDataSetChanged();
	}

	@AfterViews
	public void initView() {
		Info receiveInfo = getInfoBean();
		Object data = receiveInfo.getData();
		goodsList=(List<Goods>)data;
		Log.i("goodsList", ""+goodsList.toString());
		if(returnOrderAdapter==null){
			returnOrderAdapter=new ReturnOrderAdapter(mActivity,goodsList);
			include_returnorder_lv.setAdapter(returnOrderAdapter);
		}
		returnOrderAdapter.notifyDataSetChanged();
	}

	@Click(R.id.include_returnorder_adjustorder)
	public void adjustOrder(){
		// 清空购物车
		mShoppingCarModel.clearShopppingCar();
		// 重置确认订单页面
		EventBus.getDefault().post(new EventRestConfirm());
		// 跳转到商品列表
		openActivity(ShopInfoActivity.class, null);
		finish();
	}


	@Override
	public boolean backOperate() {
		// TODO Auto-generated method stub
		return false;
	}

}
